import { Entity, Column, Index, OneToMany } from 'typeorm';
import { BaseEntity } from './base.entity';
import { IndexInfo } from './indexInfo.entity';
import { FieldInfo } from './fieldInfo.entity';

@Entity({ name: 'table_info' })
export class TableInfo extends BaseEntity {

    @Column({
        name: 'name',
        type: 'varchar',
        length: 50,
        nullable: false,
        comment: '表名称'
    })
    name!: string;

    @Column({
        name: 'template_type',
        type: 'varchar',
        length: 10,
        nullable: true,
        comment: '模板类型'
    })
    templateType?: string

    @Column({
        name: 'sub_table',
        type: 'varchar',
        length: 50,
        nullable: true,
        comment: '子表名称'
    })
    subTable?: string;


    @OneToMany(() => IndexInfo, indexInfo => indexInfo.tableInfo)
    indexInfoList!: IndexInfo[];

    @OneToMany(() => FieldInfo, fieldInfo => fieldInfo.tableInfo)
    fieldInfoList!: FieldInfo[];

}
